package com.jindy.module.filing.service.impl;

import com.jindy.common.core.domain.entity.SysUser;
import com.jindy.common.utils.DateUtils;
import com.jindy.common.utils.SecurityUtils;
import com.jindy.module.filing.domain.Filing;
import com.jindy.module.filing.mapper.FilingMapper;
import com.jindy.module.filing.service.FilingService;
import com.jindy.module.goodscollection.domain.GoodsCollection;
import com.jindy.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 报备Service业务实现类
 *
 * @author 朝夕
 * @date 2022-11-07
 */
@Service
public class FilingServiceImpl implements FilingService {

    @Resource
    private FilingMapper filingMapper;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询报备列表
     *
     * @param filing 报备
     * @return 报备列表
     */
    @Override
    public List<Filing> selectFilingList(Filing filing) {
        return filingMapper.selectFilingList(filing);
    }

    /**
     * 查询报备
     *
     * @param id 报备主键
     * @return 报备数据
     */
    @Override
    public Filing selectFilingById(String id) {
        return filingMapper.selectFilingById(id);
    }


    /**
     * 新增报备数据
     *
     * @param filing 报备
     * @return 结果
     */
    @Override
    public int insertFiling(Filing filing)
    {
        SysUser sysUser = sysUserService.selectUserByUserName(SecurityUtils.getUsername());
        filing.setCreateBy(sysUser.getUserName());
        filing.setCreateTime(DateUtils.getNowDate());
        return filingMapper.insertFiling(filing);
    }

    /**
     * 修改报备数据
     *
     * @param filing
     * @return 结果
     */
    @Override
    public int updateFiling(Filing filing) {
        SysUser sysUser = sysUserService.selectUserByUserName(SecurityUtils.getUsername());
        filing.setUpdateBy(sysUser.getUserName());
        filing.setUpdateTime(DateUtils.getNowDate());
        return filingMapper.updateFiling(filing);
    }

    /**
     * 删除报备数据
     *
     * @param id 报备主键
     * @return 结果
     */
    @Override
    public int deleteFilingById(String id)
    {
        return filingMapper.deleteFilingById(id);
    }

    /**
     * 批量删除
     *
     * @param ids 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteFilingByIds(String[] ids)
    {
        return filingMapper.deleteFilingByIds(ids);
    }

}
